import { GiteeApiService } from "./GiteeApiService"
import { User } from "./User";
import { Repo } from "./Repo";

import express from "express"
import url from "url"


const app = express();


let api: GiteeApiService = new GiteeApiService();
// const name = "yaoleyaotou1434";

app.get("/test", (req, res) => {
    let username: any = url.parse(req.url, true).query.username;
    api.getUserInfo(username, (data: User) => {
        api.getUserRepos(data.login, (data2: Repo) => {
            // console.log(data2.array);

            data.repo = data2;
            let user: User = new User(data)
            console.log(user);
            // console.log(user.repo);
            res.send(user);
        })
    });

})

app.listen(3001, () => {
    console.log("port 3001 running..");
})